/*
Generated background of colored stars.
*/
class star_field {

  int number_of_stars;  
  Star[] stars;

  star_field(int number_of_stars) {
    this.number_of_stars = number_of_stars;
    stars = new Star[number_of_stars]; 
    for(int x=0; x< number_of_stars; x++) {
      stars[x] = new Star();
    }
  }

  void math() {
    for(int x=0; x< number_of_stars; x++) {
      stars[x].math();
    }
  }


  void render() {
    for(int x=0; x< number_of_stars; x++) {
      stars[x].render();
    }
  }



  class Star {
    float x_loc;
    float y_loc;

    float velocity;
    float radius;
    color cc;

    Star() {
      this.cc = color(random(50,100),random(50,100),random(50,100));
      this.velocity = random(.3,.5);
      this.radius   = random(.5,1);
      x_loc = random(0,width);
      y_loc = random(0,height);
    }

    void math() {

      if(x_loc < -5) {
        x_loc = width+5;
      }

      x_loc = x_loc - velocity;
    }

    void render() {
      fill(cc);
      rect(x_loc,y_loc,radius,radius);
    }
  }
}

